<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Supported String Types</title>
<link rel="stylesheet" href="../../../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../index.html" title="Chapter 1. Boost.Convert 2.0">
<link rel="up" href="../charconv_converter.html" title="boost::cnv::charconv Converter">
<link rel="prev" href="formatting_support/floating_point_notation.html" title="Floating-Point Notation">
<link rel="next" href="../../design_notes.html" title="Design Notes">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="spirit-nav">
<a accesskey="p" href="formatting_support/floating_point_notation.html"><img src="../../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../charconv_converter.html"><img src="../../../images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../images/home.png" alt="Home"></a><a accesskey="n" href="../../design_notes.html"><img src="../../../images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="boost_convert.converters_detail.charconv_converter.supported_string_types"></a><a class="link" href="supported_string_types.html" title="Supported String Types">Supported
        String Types</a>
</h4></div></div></div>
<div class="toc"><dl class="toc"><dt><span class="section"><a href="supported_string_types.html#boost_convert.converters_detail.charconv_converter.supported_string_types.custom_string_types">Custom
          String Types</a></span></dt></dl></div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="boost_convert.converters_detail.charconv_converter.supported_string_types.custom_string_types"></a><a class="link" href="supported_string_types.html#boost_convert.converters_detail.charconv_converter.supported_string_types.custom_string_types" title="Custom String Types">Custom
          String Types</a>
</h5></div></div></div>
<p>
</p>
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">my_string</span>
<span class="special">{</span>
    <span class="keyword">using</span>      <span class="identifier">this_type</span> <span class="special">=</span> <span class="identifier">my_string</span><span class="special">;</span>
    <span class="keyword">using</span>     <span class="identifier">value_type</span> <span class="special">=</span> <span class="keyword">char</span><span class="special">;</span>
    <span class="keyword">using</span>       <span class="identifier">iterator</span> <span class="special">=</span> <span class="identifier">value_type</span><span class="special">*;</span>
    <span class="keyword">using</span> <span class="identifier">const_iterator</span> <span class="special">=</span> <span class="identifier">value_type</span> <span class="keyword">const</span><span class="special">*;</span>

    <span class="identifier">my_string</span> <span class="special">();</span>
    <span class="identifier">my_string</span> <span class="special">(</span><span class="identifier">const_iterator</span><span class="special">,</span> <span class="identifier">const_iterator</span> <span class="special">=</span><span class="number">0</span><span class="special">);</span>

    <span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span>    <span class="identifier">c_str</span> <span class="special">()</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">storage_</span><span class="special">;</span> <span class="special">}</span>
    <span class="identifier">const_iterator</span> <span class="identifier">begin</span> <span class="special">()</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">storage_</span><span class="special">;</span> <span class="special">}</span>
    <span class="identifier">const_iterator</span>   <span class="identifier">end</span> <span class="special">()</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">storage_</span> <span class="special">+</span> <span class="identifier">strlen</span><span class="special">(</span><span class="identifier">storage_</span><span class="special">);</span> <span class="special">}</span>
    <span class="identifier">this_type</span><span class="special">&amp;</span> <span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*);</span>

    <span class="keyword">private</span><span class="special">:</span>

    <span class="keyword">static</span> <span class="identifier">size_t</span> <span class="keyword">const</span> <span class="identifier">size_</span> <span class="special">=</span> <span class="number">12</span><span class="special">;</span>
    <span class="keyword">char</span> <span class="identifier">storage_</span><span class="special">[</span><span class="identifier">size_</span><span class="special">];</span>
<span class="special">};</span>
</pre>
<p>
          </p>
<p>
</p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">cnv</span><span class="special">::</span><span class="identifier">charconv</span> <span class="identifier">cnv</span><span class="special">;</span>

<span class="identifier">BOOST_TEST</span><span class="special">(</span>  <span class="string">"12"</span> <span class="special">==</span> <span class="identifier">convert</span><span class="special">&lt;</span><span class="identifier">my_string</span><span class="special">&gt;(</span><span class="number">12</span><span class="special">,</span> <span class="identifier">cnv</span><span class="special">).</span><span class="identifier">value</span><span class="special">());</span>
<span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="string">"0.95"</span> <span class="special">==</span> <span class="identifier">convert</span><span class="special">&lt;</span><span class="identifier">my_string</span><span class="special">&gt;(</span><span class="number">0.95</span><span class="special">,</span> <span class="identifier">cnv</span><span class="special">(</span><span class="identifier">arg</span><span class="special">::</span><span class="identifier">precision</span> <span class="special">=</span> <span class="number">2</span><span class="special">)).</span><span class="identifier">value</span><span class="special">());</span>
</pre>
<p>
          </p>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2009-2022 Vladimir
      Batov<p>
        Distributed under the Boost Software License, Version 1.0. See copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>.
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="formatting_support/floating_point_notation.html"><img src="../../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../charconv_converter.html"><img src="../../../images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../images/home.png" alt="Home"></a><a accesskey="n" href="../../design_notes.html"><img src="../../../images/next.png" alt="Next"></a>
</div>
</body>
</html>
